import { JSEncrypt } from "jsencrypt";

const publicKey = 'MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAOIMR20qO98r0sD5ey05UGFQxyX6jPcJ\n' +
  '4KrijU50Gua9FijCF/5Uv4Ch0fb6sz0URxCSxeTh11LPIUrhtqq5xhsCAwEAAQ==\n';

const privateKey = 'MIIBVQIBADANBgkqhkiG9w0BAQEFAASCAT8wggE7AgEAAkEA4gxHbSo73yvSwPl7\n' +
  'LTlQYVDHJfqM9wngquKNTnQa5r0WKMIX/lS/gKHR9vqzPRRHEJLF5OHXUs8hSuG2\n' +
  'qrnGGwIDAQABAkEA1HxgZACQWT+TlCywGhnHMkNBgLTd75aMZ3YhCH9hjkSpcJlY\n' +
  '5cYN+gSCd34K2u7fganJgomBypHdXXuXMXmV4QIhAP4evuhutCY+nfG4rZXb64mT\n' +
  'kvE/OV6kyvczK4rx2aRxAiEA47hevfQA+WY9pvBc0jXuN2NJujEZp1ESTC3F+9zo\n' +
  'qUsCIQCG2BnFjLjbcm6tTaoO01vw7PYUPdBbgGaTNfvtBtjOgQIgePwkgeFYfyi9\n' +
  'yqrbdeenR5AdxKl/irB8+zI6hOTKS98CIG6eS17zE5a+Xqh56f3AVUKUV2jok0qx\n' +
  '491wQ2kuwpm0';

// 加密
export function encrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPublicKey(publicKey) // 设置公钥
  return encryptor.encrypt(txt) // 对数据进行加密
}

// 解密
export function decrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPrivateKey(privateKey) // 设置私钥
  return encryptor.decrypt(txt) // 对数据进行解密
}